﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace Quadrant.domain.Models
{
    public class Stick
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long? Id { get; set; }
        [Required, StringLength(128)]
        public String Name { get; set; }
        public BoardPosition Position { get; set; }
        [StringLength(256)]
        public String Comments { get; set; }
    
        [Required]
        public Guid QuadrantId { get; set; }

        [JsonIgnore]
        [ForeignKey("QuadrantId")]
        public virtual Quadrant Quadrant { get; set; }
     
    }

    [ComplexType]
    public class BoardPosition
    {
        public Decimal X { get; set; }
        public Decimal Y { get; set; }
        public Byte Zone { get; set; }

        // ReSharper disable CompareOfFloatsByEqualityOperator
        [NotMapped]
        [JsonIgnore]
        public Boolean IsEmpty { get { return (this.Zone == 0 && this.X == 0 && this.Y == 0); } }
        // ReSharper restore CompareOfFloatsByEqualityOperator
    }
}
